package com.amigo.online.provider.video.mapper;

import java.util.Set;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdvSizeMapper {

    @Select({" <script>"
            + " select a.* from adv_size_tbl a where "
            + " adv_id  in "
            + " <foreach collection='advIds' item='advId' open='(' close=')' separator=','>"
            + "	#{advId}"
            + "	</foreach>"
            + " and abs(ratio - #{ratio}) = (select min(abs(ratio - #{ratio})) from adv_size_tbl where adv_id = a.adv_id )"
            + "	</script>"})
        //@Select("select a.* from adv_size_tbl a, (select adv_id,min(abs(ratio-1.2)) as ratio from adv_size_tbl GROUP BY adv_id) b where a.adv_id in (1,3) and a.adv_id = b.adv_id and abs(a.ratio -1.2) = b.ratio order by a.adv_id ")
    void getAdvSourceBySizeAndIds(@Param("ratio") double ratio, @Param("advIds") Set<Long> advIds);

}
